home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / A86V402.ZIP / EFF86.DOC < prev    next >
Text File  |  1994-12-30  |  5KB  |  107 lines

  1. Encoding of Effective Addresses
  2.  
  3. Unless you are concerned with the nitty-gritty details of 86
  4. instruction encoding, you don't need to read this file.
  5.  
  6. Every instruction with an effective address has an encoded byte,
  7. known as the effective address byte, following the 1-byte opcode
  8. for the instruction. (For obscure reasons, Intel calls this byte
  9. the ModRM byte.)  If the effective address is a memory variable,
  10. or an indexed memory location with a non-zero constant offset,
  11. then the effective address byte will be immediately followed by
  12. the offset amount.  Amounts in the range -128 to +127 are given
  13. by a single signed byte, denoted by "d8" in the table below.
  14. Amounts requiring a 2-byte representation are denoted by "d16" in
  15. the table below.  As with all 16-bit memory quantities in the 86
  16. family, the word is stored with the least significant byte FIRST.
  17.  
  18. The following table of effective address byte values is organized
  19. into 32 rows and 8 columns.  The 32 rows give the possible values
  20. for the effective address operand: 8 registers and 24 memory
  21. indexing modes.  A 25th indexing mode, [BP] with zero
  22. displacement, has been pre-empted by the simple-memory-variable
  23. case.  If you code [BP] with no displacement, you will get
  24. [BP]+d8, with a d8-value of zero.
  25.  
  26. The 8 columns of the table reflect further information given by
  27. the effective address byte.  Usually, this is the identity of the
  28. other (always a register) operand of a 2-operand instruction.
  29. Those instructions are identified by a "/r" following the opcode
  30. byte in the instruction list.  Sometimes, the information given
  31. supplements the opcode byte in identifying the instruction
  32. itself.  Those instructions are identified by a "/" followed by a
  33. digit from 0 through 7.  The digit tells which of the 8 columns
  34. you should use to find the effective address byte.
  35.  
  36. For example, suppose you have a perverse wish to know the precise
  37. bytes encoded by the instruction SUB B[BX+17],100.  This
  38. instruction subtracts an immediate quantity, 100, from an
  39. effective address quantity, B[BX+17].  By consulting the
  40. instruction list, you find the general form SUB eb,ib.  The
  41. opcode bytes given there are 80 /5 ib.  The "/5" denotes an
  42. effective address byte, whose value will be taken from column 5
  43. of the following table.  The offset 17 decimal, which is 11 hex,
  44. will fit in a single "d8" byte, so we take our value from the
  45. "[BX] + d8" row.  The table tells us that the effective address
  46. byte is 6F.  Immediately following the 6F is the offset, 11 hex.
  47. Following that is the ib-value of 100 decimal, which is 64 hex.
  48. So the bytes generated by SUB B[BX+17],100 are 80 6F 11 64.
  49.  
  50. Table of Effective Address byte values
  51.  
  52. s  =     ES   CS   SS   DS
  53. rb =     AL   CL   DL   BL   AH   CH   DH   BH
  54. rw =     AX   CX   DX   BX   SP   BP   SI   DI
  55. digit=    0    1    2    3    4    5    6    7
  56.                                                   Effective
  57. EA byte                                           address:
  58. values:  00   08   10   18   20   28   30   38    [BX + SI]
  59.          01   09   11   19   21   29   31   39    [BX + DI]
  60.          02   0A   12   1A   22   2A   32   3A    [BP + SI]
  61.          03   0B   13   1B   23   2B   33   3B    [BP + DI]
  62.  
  63.          04   0C   14   1C   24   2C   34   3C    [SI]
  64.          05   0D   15   1D   25   2D   35   3D    [DI]
  65.          06   0E   16   1E   26   2E   36   3E    d16 (simple var)
  66.          07   0F   17   1F   27   2F   37   3F    [BX]
  67.  
  68.          40   48   50   58   60   68   70   78    [BX + SI] + d8
  69.          41   49   51   59   61   69   71   79    [BX + DI] + d8
  70.          42   4A   52   5A   62   6A   72   7A    [BP + SI] + d8
  71.          43   4B   53   5B   63   6B   73   7B    [BP + DI] + d8
  72.  
  73.          44   4C   54   5C   64   6C   74   7C    [SI] + d8
  74.          45   4D   55   5D   65   6D   75   7D    [DI] + d8
  75.          46   4E   56   5E   66   6E   76   7E    [BP] + d8
  76.          47   4F   57   5F   67   6F   77   7F    [BX] + d8
  77.  
  78.          80   88   90   98   A0   A8   B0   B8    [BX + SI] + d16
  79.          81   89   91   99   A1   A9   B1   B9    [BX + DI] + d16
  80.          82   8A   92   9A   A2   AA   B2   BA    [BP + SI] + d16
  81.          83   8B   93   9B   A3   AB   B3   BB    [BP + DI] + d16
  82.  
  83.          84   8C   94   9C   A4   AC   B4   BC    [SI] + d16
  84.          85   8D   95   9D   A5   AD   B5   BD    [DI] + d16
  85.          86   8E   96   9E   A6   AE   B6   BE    [BP] + d16
  86.          87   8F   97   9F   A7   AF   B7   BF    [BX] + d16
  87.  
  88.          C0   C8   D0   D8   E0   E8   F0   F8    ew=AX   eb=AL
  89.          C1   C9   D1   D9   E1   E9   F1   F9    ew=CX   eb=CL
  90.          C2   CA   D2   DA   E2   EA   F2   FA    ew=DX   eb=DL
  91.          C3   CB   D3   DB   E3   EB   F3   FB    ew=BX   eb=BL
  92.  
  93.          C4   CC   D4   DC   E4   EC   F4   FC    ew=SP   eb=AH
  94.          C5   CD   D5   DD   E5   ED   F5   FD    ew=BP   eb=CH
  95.          C6   CE   D6   DE   E6   EE   F6   FE    ew=SI   eb=DH
  96.          C7   CF   D7   DF   E7   EF   F7   FF    ew=DI   eb=BH
  97.  
  98. d8 denotes an 8-bit displacement following the EA byte, to be
  99. sign-extended and added to the index.
  100.  
  101. d16 denotes a 16-bit displacement following the EA byte, to be
  102. added to the index.
  103.  
  104. Default segment register is SS for effective addresses containing
  105. a BP index; DS for other memory effective addresses.
  106.  
  107.